package com.ushine.web.log.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * @author yls
 */
@Entity
@Data
@ApiModel(description = "系统日志")
@Table(name = "log")
@org.hibernate.annotations.Table(appliesTo = "log", comment = "系统日志表")
@TableName(value = "log")
public class Log implements Serializable {

    /**
     * 任务编号
     */
    @ApiModelProperty(value = "主键id:任务编号", example = "0")
    @Id
    @Column(name = "id", columnDefinition = "bigint comment 'id主键:任务编号'")
    private Long id;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime = new Date();

    /**
     * 创建人
     */
    @ApiModelProperty("创建人")
    @Column(name = "create_username", columnDefinition = "varchar(32) comment '创建人'")
    @TableField(value = "create_username", fill = FieldFill.INSERT)
    private String createUserName;

    @ApiModelProperty("操作类型")
    @Column(name = "operation", columnDefinition = "tinyint comment '操作类型'")
    private Integer operation;

    @ApiModelProperty("方法名")
    @Column(name = "method", columnDefinition = "varchar(255) comment '方法名'")
    private String method;

    @ApiModelProperty("方法中文释义")
    @Column(name = "method_name", columnDefinition = "varchar(255) comment '方法中文释义'")
    private String methodName;

    @ApiModelProperty("方法所属模块中文释义")
    @Column(name = "class_name", columnDefinition = "varchar(255) comment '方法所属模块中文释义'")
    private String className;

    @ApiModelProperty("参数")
    @Column(name = "params", columnDefinition = "text comment '参数'")
    private String params;

    @ApiModelProperty("ip地址")
    @Column(name = "ip", columnDefinition = "varchar(32) comment 'ip地址'")
    private String ip;

    @ApiModelProperty("请求URI")
    @Column(name = "request_uri", columnDefinition = "varchar(255) comment '请求URI'")
    private String requestUri;

    @ApiModelProperty("请求类型")
    @Column(name = "request_method", columnDefinition = "varchar(255) comment '请求类型'")
    private String requestMethod;

    @ApiModelProperty("异常描述")
    @Column(name = "exception_log", columnDefinition = "text comment '异常描述'")
    private String exceptionLog;

    @ApiModelProperty("日志类型")
    @Column(name = "type", columnDefinition = "varchar(255) comment '日志类型'")
    private String type;

    @ApiModelProperty("执行时间/ms")
    @Column(name = "execute_time", columnDefinition = "bigint comment '执行时间/ms'")
    private Long executeTime;

}
